from PyDialog import PyDialog
from etgui import *
from PageLayout import *
import CmdNo

class YesNoDialog(PyDialog):
	wflags = eWinBlock	# modal dialog
	title = 'Yes or No'
	def __init__(self, title, str=''):
		self.title = title
		self.text = MultilineTextItem(str)
		self.answer = None
	def SetString(self, str):
		self.text.SetString(str)
	def ShowUnderMouse(self):
		self.impl.ShowUnderMouse()
	def MakeContent(self):
		return MakeDialogWithButtons(
			self.text,
			ActionButton(CmdNo.cIdOk, 'OK', default=1),
			ActionButton(CmdNo.cIdCancel, 'Cancel')
		)
	def Yes(self):
		self.answer = 1
	def No(self):
		self.answer = 0
	def Answer(self):
		return self.answer
	def Control(self,id,part,val):
		if id==CmdNo.cIdOk:
			self.answer = 1
			return 0
		elif id==CmdNo.cIdCancel:
			self.answer = 0
			return 0
		return 0
 
